import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import 'sample_bloc.dart';
class FlutterBlocDemoHome extends StatefulWidget {
  const FlutterBlocDemoHome({Key? key}) : super(key: key);

  @override
  _FlutterBlocDemoHomeState createState() => _FlutterBlocDemoHomeState();
}

class _FlutterBlocDemoHomeState extends State<FlutterBlocDemoHome> {
  CounterBloc _bloc = CounterBloc();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: BlocBuilder<CounterBloc,CounterState>(
        cubit: _bloc,
        builder: (context,state){
          return Center(
            child: Text("${state.count}",style: TextStyle(fontSize: 28),),
          );
        },
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: (){
          _bloc.increment();
        },
        child: Icon(Icons.add),
      ),
    );
  }
}
